package org.td.engine;

import org.td.engine.entity.Entity;
import org.td.engine.entity.Monster;

public class TowerPickFilter implements PickFilter {
    
    private float x;
    private float y;
    private float radius;
    
    public TowerPickFilter(float x, float y, float radius) {
        this.x = x;
        this.y = y;
        this.radius = radius;
    }
    
    @Override
    public boolean accept(Entity e) {
        if (!(e instanceof Monster)) {
            return false;
        } else {
            Monster m = (Monster)e;
            if (m.getHealth() <= 0) {
                return false;
            }
        }
        double dist = Math.sqrt((e.getX()-x)*(e.getX()-x) + (e.getY()-y)*(e.getY()-y));
        return dist <= radius;
    }
}
